package edu.hawaii.stack.page;

import org.apache.wicket.Page;
import org.apache.wicket.Request;
import org.apache.wicket.Response;
import org.apache.wicket.Session;
import org.apache.wicket.protocol.http.WebApplication;

/**
 * A top level class required for a wicket application.
 * 
 * @author Aric West
 */
public class StackApplication extends WebApplication {
  
  @Override
  public Class<? extends Page> getHomePage() {
    return StackPage.class;
  }

  /**
   * Return a session object to hold the models for each user of this application.
   * @param request The http request.
   * @param response The http response. 
   * @return The session instance for this user. 
   */
  @Override
  public Session newSession(Request request, Response response) {
    return new StackSession(this, request);
  }

  /**
   * Return this webapp. Using this, you can get the session for your current user instance.
   * 
   * @return The webapp.
   */
  public static StackApplication get() {
    return (StackApplication) WebApplication.get();
  }  
}
